package domfarr.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * Person entity.
 * 
 * @author Dominic Farr
 * 
 */
@Entity
@Table(name = "PERSONS")
public final class Person implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	@Column(name = "ID")
	private Long id;
	
	@Embedded
	private Name name;

	@Embedded
	private ContactDetails contactDetails;

	public Person() {
	}

	public ContactDetails getContactDetails() {
		return contactDetails;
	}

	public void setContactDetails(ContactDetails contactDetails) {
		this.contactDetails = contactDetails;
	}

	public Person(final Name name, final ContactDetails contactDetails) {
		this.name = name;
		this.contactDetails = contactDetails;
	}

	public Long getId() {
		return id;
	}

	public Name getName() {
		return name;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setName(Name name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}

	@Override
	public boolean equals(final Object rhs) {
		return EqualsBuilder.reflectionEquals(this, rhs);
	}
	
	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
}
